home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Syn Text Editor 2.1.0.46 / synsetup-2.1.0.46.exe / {app} / scripts / getfriend.vbs < prev    next >
Text File  |  2003-08-13  |  3KB  |  74 lines

  1. ' Caption: Get Friend File|
  2. ' Hint: Opens the corresponding .h / .cpp file|
  3. ' Icon: getfriend.ico|
  4. '
  5. '  syn
  6. '  Copyright (C) 2000-2003, Ascher Stefan. All rights reserved.
  7. '  stievie@utanet.at, http://web.utanet.at/ascherst/
  8. '
  9. '  The contents of this file are subject to the Mozilla Public License
  10. '  Version 1.1 (the "License"); you may not use this file except in compliance
  11. '  with the License. You may obtain a copy of the License at
  12. '  http://www.mozilla.org/MPL/
  13. '
  14. '  Software distributed under the License is distributed on an "AS IS" basis,
  15. '  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
  16. '  the specific language governing rights and limitations under the License.
  17. '
  18. '  The Original Code is getfriend.vbs, released Sun, 26 May 2002 10:55:39 UTC.
  19. '
  20. '  The Initial Developer of the Original Code is Ascher Stefan.
  21. '  Portions created by Ascher Stefan are Copyright (C) 2000-2003 Ascher Stefan.
  22. '  All Rights Reserved.
  23. '
  24. '  Contributor(s): .
  25. '
  26. '  Alternatively, the contents of this file may be used under the terms of the
  27. '  GNU General Public License Version 2 or later (the "GPL"), in which case
  28. '  the provisions of the GPL are applicable instead of those above.
  29. '  If you wish to allow use of your version of this file only under the terms
  30. '  of the GPL and not to allow others to use your version of this file
  31. '  under the MPL, indicate your decision by deleting the provisions above and
  32. '  replace them with the notice and other provisions required by the GPL.
  33. '  If you do not delete the provisions above, a recipient may use your version
  34. '  of this file under either the MPL or the GPL.
  35. '
  36. '  You may retrieve the latest version of this file at the syn home page,
  37. '  located at http://syn.sourceforge.net/
  38. '
  39. ' $Id: getfriend.vbs,v 1.3.2.5 2003/08/13 00:38:45 neum Exp $
  40.  
  41. option explicit
  42.  
  43. '#include <cmnfunc>
  44.  
  45. sub Main(dummy)
  46.   dim currentFileName, newFileName
  47.   dim ext
  48.   if Documents.Count = 0 then
  49.     MsgBox "Not Document open.", vbCritical
  50.     exit sub
  51.   end if
  52.   currentFileName = ActiveDocument.FileName
  53.   ext = LCase(ExtractFileExt(currentFileName))
  54.   if (ext <> ".c") and (ext <> ".cpp") and (ext <> ".h") then
  55.     MsgBox "This Script requires either a *.cpp, *.c or *.h File.", vbCritical
  56.     exit sub
  57.   end if
  58.   newFileName = ""
  59.   if (ext = ".h") then
  60.     newFileName = ChangeFileExt(currentFileName, ".cpp")
  61.     if not FileExists(newFileName) and FileExists(ChangeFileExt(newFileName, ".c")) then
  62.       newFileName = ChangeFileExt(newFileName, ".c")
  63.     end if
  64.   elseif (ext = ".cpp") or (ext = ".c") then
  65.     newFileName = ChangeFileExt(currentFileName, ".h")
  66.   end if
  67.  
  68.   if FileExists(newFileName) then
  69.     Documents.Open false, newFileName, false
  70.   else
  71.     MsgBox "Corresponding file " & newFileName & " not found.", vbCritical
  72.   end if
  73. end sub
  74.